<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>日常巡检统计</title>
    <%@include file="../../public/commonCss.jsp" %>
    <%@include file="../../public/commonJs.jsp" %>
</head>
<body ms-controller="main" class="ms-controller">
<div id="wrapper">
    <div class="boxtoolbar whiteBox actionArea contentbox">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" style="height:30px;" ms-duplex="searchKey.startDate"
                       class="layui-input Wdate" onClick="WdatePicker({readOnly:true,maxDate:'%y-%M-%d'})"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal layui-btn-small" ms-on-click="searchData()">搜索</button>
            </div>
        </div>
    </div>
    <div class="boxmain whiteBox lrbox boxdisplay" style="margin-top:-90px">
        <div class="lrboxmain borderL">
            <div class="from-header borderB contentbox">
                <span class="font14">所属分类:</span><span
                    style="color:blue;">${loginInfo.roadName}-${loginInfo.trainCode}</span>
                <span class="fr">
                    <select onchange="selectChange(this)" style="display: inline-block" ms-duplex='selectTrainCode'>
                        <option value="">--选择车次--</option>
                        <option ms-attr-value='el.code' ms-repeat='trainCodes'>{{el.code}}</option>
                    </select>
                    <button class="layui-btn layui-btn-normal layui-btn-small" onclick="exportExcel()">导出excel</button>
                </span>
            </div>
            <div class="from-body withheader contentbox" style=" overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>行号</th>
                        <th>功能或者目录</th>
                        <th>工序名称</th>
                        <th>工序状态</th>
                        <th>开始时间</th>
                        <th>结束时间</th>
                        <th>工序扣分</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ms-repeat="tableDatas">
                        <td>{{$index+1}}</td>
                        <td>
                            <span ms-if="el.isCatelog==1" style="color:blue">功能</span>
                            <span ms-if="el.isCatelog==0&&el.catalogDepth!=1" style="color:#009688">子目录</span>
                            <span ms-if="el.isCatelog==0&&el.catalogDepth==1" style="color:#FF5722">主目录</span>
                        </td>
                        <td align="left">
                            <span style="margin-left:0px" ms-if="el.catalogDepth==1">{{el.workName}}
                                <span style="color:red;margin-left:15px">({{el.workPlanTime}})</span>
                            </span>
                            <span style="margin-left:50px" ms-if="el.catalogDepth==2">{{el.workName}}</span>
                            <span style="margin-left:100px" ms-if="el.catalogDepth==3">{{el.workName}}</span>
                            <span style="margin-left:150px" ms-if="el.catalogDepth==4">{{el.workName}}</span>
                            <span style="margin-left:200px" ms-if="el.catalogDepth==5">{{el.workName}}</span>
                        </td>
                        <td>
                            <span ms-if="el.workStatus==0" style="color:red">未开始</span>
                            <span ms-if="el.catalogDepth==1&&el.workStatus==1" style="color:red">进行中</span>
                            <span ms-if="el.catalogDepth>1&&el.workStatus==1" style="color:green">已完成</span>
                            <span ms-if="el.workStatus==2" style="color:green">正常完成</span>
                            <span ms-if="el.workStatus==3" style="color:#ffb76c">提前完成</span>
                            <span ms-if="el.workStatus==4" style="color:blue">推迟完成</span>
                        </td>
                        <td><span ms-if="el.beginTime!=''&&el.beginTime!=null">{{el.beginTime|date('HH:mm:ss')}}</span>
                        </td>
                        <td>
                            <span ms-if="el.finishTime!=''&&el.finishTime!=null">{{el.finishTime|date('HH:mm:ss')}}</span>
                        </td>
                        <td>{{el.score}}分</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- whitebox -->
</div>
<script type="text/javascript">
    var vm;
    avalon.ready(function () {
        vm = avalon.define({
            $id: "main",
            tableDatas: [],//图片数据
            treeDatas: [],//菜单数据
            trainCodes: [],//车次
            selectTrainCode: '${trainCode}',
            searchKey: {
                startDate: '${startDate}',
                searchKey: '',
                loginId: '${loginInfo.id}',
                trainCode: '${trainCode}',
            },
            selectNode: {},
            userTrainScore: {}
        })
        avalon.scan();
        loadTableData();
    });

    //查询用户车次得分数据
    function loadUserScore() {
        ajaxUtil.post("${ctx}/countController/selectUserTrainScore.action", vm.$model.searchKey, false, function (data) {
            vm.userTrainScore = data.data;
        })
    }

    //导出excel
    function exportExcel() {
        layerUtil.fail("功能暂未启用");
    }

    //搜索
    function searchData() {
        loadTreeData();
    }

    //当select值改变的时候触发
    function selectChange(_this) {
        var selectValue = $(_this).val();
        vm.searchKey.trainCode = selectValue;
        loadTableData2();
    }

    //初始化分页插件的方法
    function loadTableData2() {
        ajaxUtil.post("${ctx}/countController/selectUserWorkByTrainCode.action", vm.$model.searchKey, true, function (data) {
            vm.tableDatas = data.datas;
        })
    }

    function loadTableData() {
        ajaxUtil.post("${ctx}/countController/selectUserWorkByLoginId.action", vm.$model.searchKey, true, function (data) {
            vm.tableDatas = data.datas;
            vm.trainCodes = data.trains;
            vm.selectTrainCode = data.trainCode;
            vm.userScore = data.userScore;
        })
    }

</script>
</body>
</html>